// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2024 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.13.1
package sys

import (
	"context"
	"hotgo/api/admin/stockzhaindex"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	StockZhAIndex = cStockZhAIndex{}
)

type cStockZhAIndex struct{}

// List 查看指数列表
func (c *cStockZhAIndex) List(ctx context.Context, req *stockzhaindex.ListReq) (res *stockzhaindex.ListRes, err error) {
	list, totalCount, err := service.SysStockZhAIndex().List(ctx, &req.StockZhAIndexListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.StockZhAIndexListModel{}
	}

	res = new(stockzhaindex.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新指数
func (c *cStockZhAIndex) Edit(ctx context.Context, req *stockzhaindex.EditReq) (res *stockzhaindex.EditRes, err error) {
	err = service.SysStockZhAIndex().Edit(ctx, &req.StockZhAIndexEditInp)
	return
}

// View 获取指定指数信息
func (c *cStockZhAIndex) View(ctx context.Context, req *stockzhaindex.ViewReq) (res *stockzhaindex.ViewRes, err error) {
	data, err := service.SysStockZhAIndex().View(ctx, &req.StockZhAIndexViewInp)
	if err != nil {
		return
	}

	res = new(stockzhaindex.ViewRes)
	res.StockZhAIndexViewModel = data
	return
}
